package br.com.persist.core;

import java.util.ArrayList;
import java.util.List;

import br.com.persist.api.Command;
import br.com.persist.api.PersistentContext;
import br.com.persist.api.RuntimeExecutionException;
import br.com.persist.api.VolatileContext;

public class ScriptPersistResource extends PersistResource {

	private List<Command> commands = new ArrayList<Command>();

	@Override
	protected Object run(VolatileContext volatileContext,
			PersistentContext persistentContext)
			throws RuntimeExecutionException {
		for (Command command : commands) {
			command.execute(volatileContext, persistentContext);
		}
		return null;
	}

	public void add(Command command) {
		this.commands.add(command);
	}
}
